<%--
  Created by IntelliJ IDEA.
  User: 我的大名叫陆健伟
  Date: 2016/3/1
  Time: 11:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>投诉详情</title>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'></c:url>">
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/main.css'></c:url>">
    <style type="text/css">
        .ui-form-item label:not(.ui-switch):not(.ui-checkbox):not(.ui-radio){width: 105px; text-align: right;}
        .ui-form-item input, .ui-form-item textarea{padding-left: 105px;}
        .ui-select select{width: 90%; margin-left: 5%;}
    </style>
</head>
<body class="body_bg" ontouchstart>
<section class="ui-container">
    <div class="ui-form-item ui-form-item-show ui-border-tb bg_fff" style="margin-top: 10px;">
        <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">举报内容</label>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#">事项名称:</label>
        <input type="text" placeholder="" id="sxmc" readonly>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#" style="width: 135px;">举报事项发生日期:</label>
        <input type="text" placeholder="" id="jbsxTime" readonly style="padding-left: 135px">
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#">举报事项经过:</label>
        <input type="text" placeholder="" readonly id="jbsxjg">
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-tb bg_fff" style="margin-top: 10px;display: none" id="hfnr">
        <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">回复内容</label>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff" style="display: none" id="yhfnr">
        <label for="#">回复内容:</label>
        <input type="text" placeholder="" readonly>
    </div>
    <%--<div class="ui-form-item ui-form-item-show ui-border-b bg_fff" style="display: none"  id="sldw">
        <label for="#">受理单位:</label>
        <input type="text" placeholder="" readonly>
    </div>--%>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff" style="display: none"  id="clsj">
        <label for="#">处理时间:</label>
        <input type="text" placeholder="" readonly>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff" style="position: relative; height: 80px;display: none" id="mydpj">
        <label for="#" class="h1_text" style="width: 80%;color: #666;font-size: 16px;text-align: left; ">满意度评价:</label>
        <div style="position: absolute; right: 25px; top: 35px;">
            <label class="ui-radio" for="radio">
                <input type="radio" name="radio" checked="checked" value="0">
            </label>
            满意
            <label class="ui-radio" for="radio">
                <input type="radio" name="radio" value="1">
            </label>
            基本满意
            <label class="ui-radio" for="radio">
                <input type="radio" name="radio" value="2">
            </label>
            不满意

        </div>
    </div>
    <div class="ui-btn-wrap" id="bz" style="display: none">
        <button class="ui-btn-lg ui-btn-primary">
            保存
        </button>
    </div>
</section>
</body>
<script src="<c:url value='/resource/wechat/js/zepto.min.js'/>"></script>
<script>
    var projectBillId = "";
    $(function(){
        $.ajax({
            url : "<c:url value='/api/complaint/detail/'/>" + "${projectGuid}",
            type : "get",
            dataType : "json",
            success : function(resp){
                if(resp&&resp.succ){
                    var _data = resp.data;
                    var compltCenter = _data.compltCenter,compltCenterReply = _data.compltCenterReply;
                    var _html = "";
                    var bjbrxm = compltCenter.bjbrxm==null?"":compltCenter.bjbrxm;
                    var bjbrdw = compltCenter.bjbrdw==null?"":compltCenter.bjbrdw;
                    var jzmc = compltCenter.jzmc==null?"":compltCenter.jzmc;
                    var zw = compltCenter.zw==null?"":compltCenter.zw;
                    var rs = compltCenter.rs==null?"":compltCenter.rs;
                    var jh = compltCenter.temp1==null?"":compltCenter.temp1;
                    if(compltCenter.type == 0){
                        _html += '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">被举报人信息</label></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">被举报人姓名:</label><input type="text" readonly placeholder="" value="' + bjbrxm + '"></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label style="color: #666;">警号:</label><input type="text" readonly placeholder="" value="' + jh + '"></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">被举报人单位:</label><input readonly type="text" value="' + bjbrdw + '" placeholder=""></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">警种:</label><input type="text" value="' + jzmc + '" placeholder="" readonly></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">职务:</label><input readonly type="text" value="' + zw + '" placeholder=""></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">人数:</label><input readonly value="' + rs + '" type="text" placeholder=""></div>';
                        $(".ui-container").prepend(_html);
                        $("#xb").val(compltCenter.xb);
                    }else if(compltCenter.type == 1){
                        _html += '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">被举报单位信息</label></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">人数:</label><input readonly type="text" value="' + rs +'" placeholder=""></div>'
                                    + '<div class="ui-form-item ui-form-item-show ui-border-b bg_fff"><label for="#">警种:</label><input type="text" value="' + jzmc + '" placeholder="" readonly></div>';
                        $(".ui-container").prepend(_html);
                    }
                    projectBillId = _data.projectBillId;
                    $("#sxmc").val(compltCenter.sxmc);
                    $("#jbsxTime").val(compltCenter.jbsxTime);
                    $("#jbsxjg").val(compltCenter.jbsxjg);
                    if(compltCenter.isReply == "1") {
                        $("#hfnr").css("display", "block");
                        $("#yhfnr").css("display", "block");
                        //$("#sldw").css("display", "block");
                        $("#clsj").css("display", "block");
                        $("#yhfnr input").val(compltCenterReply.backContent);
                        //$("#sldw input").val(compltCenterReply.backUnit);
                        $("#clsj input").val(compltCenterReply.createTime);
                        if (_data.isMydPj == "0") {
                            $("#mydpj").css("display", "block");
                            $("#bz").css("display", "block");
                        }else if(_data.isMydPj == "1"){
                            $("#mydpj").css("display", "block");
                            $("input[type='radio']").each(function(){
                                $(this).attr("disabled", true);
                                if(this.value == _data.evaluationGrade){
                                    this.checked = true;
                                }
                            })
                        }
                    }
                }else {
                    alert(resp.msg);
                }
            }
        });

    })

    $("#bz button").click(function(){
        var evaluationContent = "";
        var evaluationGrade = "";
        var radioInput = $("#mydpj input");
        for(var i=0;i<radioInput.length;i++){
            var _item = radioInput[i];
            if(_item.checked && _item.value == "0"){
                evaluationContent = "满意";
                evaluationGrade = "0";
            }else if(_item.checked && _item.value == "1"){
                evaluationContent = "基本满意";
                evaluationGrade = "1";
            }else if(_item.checked && _item.value == "2"){
                evaluationContent = "不满意";
                evaluationGrade = "2";
            }
        }
        $.ajax({
            url : "<c:url value='/api/matters/product/myd'/>",
            type : "post",
            data : '{"evaluationGrade":"' + evaluationGrade + '","prjGuid":"' + projectBillId + '","evaluaTionType":"' + 3 + '","createUserName":"' + "${userName}" + '","evaluationContent":"' + evaluationContent + '","createUserId":"' + "${userGuid}" + '"}',
            dataType : "json",
            contentType : "application/json;charset=utf-8",
            async : false,
            success : function(resp){
                if(resp&&resp.succ){
                    alert(resp.msg);
                    window.location.href = "<c:url value='/api/complaint/compltIndex'/>";
                }else {
                    alert(resp.msg);
                }
            }
        });
    });
</script>

</html>
